package com.ruoyi.web.controller.his;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HisEngineWarnType;
import com.ruoyi.system.service.IHisEngineWarnTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预警类型Controller
 * 
 * @author Alan
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/system/type")
public class HisEngineWarnTypeController extends BaseController
{
    @Autowired
    private IHisEngineWarnTypeService hisEngineWarnTypeService;

    /**
     * 查询预警类型列表
     */
//    @PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisEngineWarnType hisEngineWarnType)
    {
        startPage();
        List<HisEngineWarnType> list = hisEngineWarnTypeService.selectHisEngineWarnTypeList(hisEngineWarnType);
        return getDataTable(list);
    }

    /**
     * 导出预警类型列表
     */
//    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "预警类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HisEngineWarnType hisEngineWarnType)
    {
        List<HisEngineWarnType> list = hisEngineWarnTypeService.selectHisEngineWarnTypeList(hisEngineWarnType);
        ExcelUtil<HisEngineWarnType> util = new ExcelUtil<HisEngineWarnType>(HisEngineWarnType.class);
        return util.exportExcel(list, "预警类型数据");
    }

    /**
     * 获取预警类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(hisEngineWarnTypeService.selectHisEngineWarnTypeById(id));
    }

    /**
     * 新增预警类型
     */
//    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "预警类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisEngineWarnType hisEngineWarnType)
    {
        return toAjax(hisEngineWarnTypeService.insertHisEngineWarnType(hisEngineWarnType));
    }

    /**
     * 修改预警类型
     */
//    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "预警类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisEngineWarnType hisEngineWarnType)
    {
        return toAjax(hisEngineWarnTypeService.updateHisEngineWarnType(hisEngineWarnType));
    }

    /**
     * 删除预警类型
     */
//    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "预警类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(hisEngineWarnTypeService.deleteHisEngineWarnTypeByIds(ids));
    }
}
